﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections;
using System.Collections.Generic;
using ScrumTable.Common;

#endregion

namespace ScrumTable.BL.DM.DataManagement
{
    /// <summary>
    /// Represents the method that handles the CollectionChanged event.
    /// </summary>
    /// <param name="sender">Specifies the sender of the event. This may be the collection itself or the underlying context.</param>
    /// <param name="e">Arguments which contain information about the event.</param>
    public delegate void DomainCollectionChangedEventHandler(object sender, DomainCollectionChangedEventArgs e);

    /// <summary>
    /// Describes the action that caused a CollectionChanged event.
    /// </summary>
    public enum DomainCollectionChangedAction
    {
        /// <summary>
        /// A multiple event has been fired, see child collection for more information.
        /// </summary>
        None = 0,

        /// <summary>
        /// One item was added to the collection.
        /// </summary>
        Add,

        /// <summary>
        /// One item was removed from the collection.
        /// </summary>
        Remove,

        /// <summary>
        /// One item was moved within the collection.
        /// </summary>
        Move,

        /// <summary>
        /// The content of the collection changed dramatically.
        /// </summary>
        Reset
    } 


    /// <summary>
    /// Represents the an event arguments class which contains additional
    /// information about an event if something has changed inside a
    /// domain collection object.
    /// </summary>
    public class DomainCollectionChangedEventArgs : EventArgs
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Describes the action that caused a CollectionChanged event.
        /// </summary>
        public DomainCollectionChangedAction Action { get; private set; }

        /// <summary>
        /// Gets the owner collection of the item.
        /// </summary>
        public ICollection Owner { get; private set; }

        /// <summary>
        /// Gets the item which caused the collection change, if an
        /// item is available.
        /// </summary>
        public DomainBase ChangedItem { get; private set; }
        
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new DomainChangedEventArgs instance. This constructor
        /// is protected internal because its needed by derived or package classes only.
        /// </summary>
        /// <param name="action">Specifies the changed action reason.</param>
        /// <param name="owner">Specifies the parent collection instance.</param>
        /// <param name="changedItem">Specifies the item which raised the event.</param>
        internal protected DomainCollectionChangedEventArgs(DomainCollectionChangedAction action, ICollection owner, DomainBase changedItem)
        {
            PreCondition.AssertNotNull(owner, "owner");

            Action = action;
            Owner = owner;
            ChangedItem = changedItem;
        }

        /// <summary>
        /// Creates a new DomainChangedEventArgs instance. This constructor
        /// is protected internal because its needed by derived or package classes only.
        /// </summary>
        /// <param name="action">Specifies the changed action reason.</param>
        /// <param name="owner">Specifies the parent collection instance.</param>
        internal protected DomainCollectionChangedEventArgs(DomainCollectionChangedAction action, ICollection owner)
            : this(action, owner, null)
        {
        }

        /// <summary>
        /// Creates a new DomainChangedEventArgs instance. This constructor
        /// is protected internal because its needed by derived or package classes only.
        /// </summary>
        /// <param name="action">Specifies the changed action reason.</param>
        protected DomainCollectionChangedEventArgs(DomainCollectionChangedAction action)
        {
            Action = action;
        }


        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}